#!/bin/bash

if [ -f /data/local/tmp/stop ];then
   busybox  rm /data/local/tmp/stop
fi


rm -rf /data/local/tmp/result/meminfo
if [ ! -d "/data/local/tmp/result" ]; then
	mkdir /data/local/tmp/result
fi
#cd /data/local/tmp/result
mkdir /data/local/tmp/result/meminfo
cd ..


count=1
while [ $count -le 1000 ];do
	if [ -f /data/local/tmp/stop ];then
            echo "Found stop file!!!"
            break
        fi
	
	time=`date "+%H:%M:%S"`
	focusedAc=`dumpsys activity | busybox grep 'mFocusedActivity' | busybox awk '{print $4}'`
	echo -en "$time\t$focusedAc\n" > /data/local/tmp/result/meminfo/$count.txt
	dumpsys meminfo | grep -v 'warning' >> /data/local/tmp/result/meminfo/$count.txt
	sleep 10
	count=$(( $count + 1))

done

